#include <stdio.h>
#include "FileInterfaceExt.h"

#pragma warning(disable:4996)

namespace FILESYS
{

bool					fs_fileTimestamp( const char *path, NxU64& outTimestamp )
{
	bool ret = true;
	outTimestamp = 0;
	return ret;
}

// reads an entire file into memory (allocated using MEMALLOC_MALLOC)
void *					fs_readEntireFile( const char *path, NxU32 &outFileSize )
{
	void *ret = NULL;
	FILE *fph = fopen(path,"rb");
	if ( fph )
	{
		fseek(fph,0L,SEEK_END);
		outFileSize = ftell(fph);
		fseek(fph,0L,SEEK_SET);
		if ( outFileSize > 0 )
		{
			ret = MEMALLOC_MALLOC(outFileSize);
			if ( ret )
			{
				size_t r = fread(ret,outFileSize,1,fph);
				if ( r != 1 )
				{
					MEMALLOC_FREE(ret);
					outFileSize = 0;
				}
			}
			else
			{
				outFileSize = 0;
			}
		}
		fclose(fph);
	}
	return ret;
}

	// if a file already exists at the specified path, returns true.  Otherwise, tries to create the file.
bool					fs_touchFile( const char *path )
{
	bool ret = false;

	FILE *fph = fopen(path,"ab+");
	if ( fph )
	{
		fclose(fph);
		ret = true;
	}
	return ret;
}

	// returns whether a file exists at the specified path.
bool					fs_fileExists( const char *path )
{
	bool ret = false;

	FILE *fph = fopen(path,"rb");
	if ( fph )
	{
		fclose(fph);
		ret = true;
	}
	return ret;
}
};